package com.sxt.bus.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.sxt.bus.domain.Car;
import com.sxt.bus.domain.Check;
import com.sxt.bus.domain.Customer;
import com.sxt.bus.domain.Rent;
import com.sxt.bus.mapper.CarMapper;
import com.sxt.bus.mapper.CheckMapper;
import com.sxt.bus.mapper.CustomerMapper;
import com.sxt.bus.mapper.RentMapper;
import com.sxt.bus.service.CheckService;
import com.sxt.bus.vo.CheckVo;
import com.sxt.sys.utils.DataGridView;
@Service
@Transactional
public class CheckServiceImpl implements CheckService {
  @Autowired
	private CheckMapper checkMapper;
  @Autowired
  private CarMapper carMapper;
  @Autowired
  private RentMapper rentMapper;
  @Autowired
  private CustomerMapper customerMapper;
	@Override
	public Map<String, Object> checkRentCarCustomer(String rentid) {
		// TODO Auto-generated method stub
		//1,查询出租单信息
				Rent rent = rentMapper.selectByPrimaryKey(rentid);
				//2,查询客户信息
				Customer customer = this.customerMapper.selectByPrimaryKey(rent.getIdentity());
				//3,查询车辆信息
				Car car = this.carMapper.selectByPrimaryKey(rent.getCarnumber());
				Map<String, Object>  map=new HashMap<String, Object>();
				map.put("rent", rent);
				map.put("customer", customer);
				map.put("car", car);
				return map;
	}
	@Override
	public void addCheck(CheckVo checkVo) {
		// TODO Auto-generated method stub
		this.checkMapper.insertSelective(checkVo);
	}
	@Override
	public DataGridView queryAllCheck(CheckVo checkVo) {
		Page<Object> page = PageHelper.startPage(checkVo.getPage(),checkVo.getRows());
		List<Check> list = this.checkMapper.queryAllCheck(checkVo);
		return new DataGridView(page.getTotal(),list);
	}
	@Override
	public void updateCheck(CheckVo checkVo) {
		this.checkMapper.updateByPrimaryKeySelective(checkVo);
		
	}

	
}
